package com.hn.vue.controller;

import com.hn.vue.pojo.Menu;
import com.hn.vue.service.MenuService;
import com.hn.vue.vo.ResponseVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * hanni
 * 2019/3/4 0004
 * 10:39
 */
@RestController
@RequestMapping("/menu")
public class MenuController {

    @Resource
    private MenuService menuService;

    @GetMapping("/getMenu")
    public List getMenu(){
       return menuService.getMenu();

    }

    @PostMapping("/save")
    public ResponseVo save(Menu menu){

        try{

            menuService.save(menu);

        }catch (Exception e){
            return ResponseVo.error("菜单保存失败");
        }
        return ResponseVo.ok("菜单保存成功");
    }





}
